﻿using System;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

//using System.Drawing;
using xbmc_json_async.System;
using xbmc_json_async.Utilities;

namespace xbmc_json_async.Media
{
    /// <summary>
    /// TV Show class, see Types.Video.Details.TVShow for property descriptions
    /// </summary>
    public class TvShow : xbmc_json_async.Types.Video.Details.TVShow
    {
        
        public TvShow(int id, string label, string thumbnail, string fanart, string plot,  string genre, int year, float rating)
        {
            throw new NotImplementedException("Use emtpy constructor and populatefrom Json");
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TvShow"/> class.
        /// </summary>
        public TvShow()
        {
            
        }

        /// <summary>
        /// Froms the json object.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public static TvShow FromJsonObject(JObject item)
        {
            var show = new TvShow();

            show.episode = XHelpers.JvalInt(item, "episode");
            show.episodeguide = XHelpers.Jval(item, "episodeguide");
            show.fanart = XHelpers.Jval(item, "fanart");
            show.file = XHelpers.Jval(item, "file");
            show.genre = XHelpers.Jval(item, "genre");
            show.imdbnumber = XHelpers.Jval(item, "imdbnumber");
            show.label = XHelpers.Jval(item, "label");
            show.lastplayed = XHelpers.Jval(item, "lastplayed");
            show.mpaa = XHelpers.Jval(item, "mpaa");
            show.originaltitle = XHelpers.Jval(item, "originaltitle");
            show.playcount = XHelpers.JvalInt(item, "playcount");
            show.plot = XHelpers.Jval(item, "plot");
            show.premiered = XHelpers.Jval(item, "premiered");
            show.rating = XHelpers.JValDouble(item, "rating");
            show.sorttitle = XHelpers.Jval(item, "sorttitle");
            show.studio = XHelpers.Jval(item, "studio");
            show.thumbnail = XHelpers.Jval(item, "thumbnail");
            show.title = XHelpers.Jval(item, "title");
            show.tvshowid = XHelpers.JvalInt(item, "tvshowid");
            show.votes = XHelpers.Jval(item, "votes");

            /*
            Injector injector = new Injector();
            var vObj = (object)show;
            show = (TvShow)injector.FillObject(vObj, (object)item);
            */

            return show;
        }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return label;
        }
    }
}
